/**
 * Copyright (C) 2006 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.opensymphony.xwork2.inject;

import static com.opensymphony.xwork2.inject.Container.DEFAULT_NAME;

import static java.lang.annotation.ElementType.*;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;

/**
 * <p>Annotates members and parameters which should have their value[s]
 * injected.
 * 
 * 关于java的注解语法请参阅Think in Java P621
 * @ Target用来定义 你的注解用在什么地方(例如是一个方法或者一个域)
 * (从这个类来看 也可以用在参数上，Think in Java一书上写到这个也可以用在ElementType.TYPE)
 * 可参见 @see ElementType
 * 注解不支持继承
 * @ Rectetion用来定义该注解在哪一个级别使用 源码(SOURCE)/类文件(CLASS)/运行时(RUNTIME)
 * 
 * 这个Inject会在容器实现的时候用到
 * 参见ContainerImpl类的 addInjectorsForMembers方法
 * Inject inject = member.getAnnotation(Inject.class);
 *
 * @author crazybob@google.com (Bob Lee)
 */
@Target({METHOD, CONSTRUCTOR, FIELD, PARAMETER})
@Retention(RUNTIME)
public @interface Inject {

  /**
   * 依赖名称
   * Dependency name. Defaults to {@link Container#DEFAULT_NAME}.
   */
  String value() default DEFAULT_NAME;

  /**
   * 这个注入是否是必须的  仅适用于方法和域
   * Whether or not injection is required. Applicable only to methods and
   * fields (not constructors or parameters).
   */
  boolean required() default true;
}
